package com.its.us.sk.server.ws.base;

import io.netty.channel.Channel;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * @Author: master
 * @Date: 2020/11/26 13:38
 * @Version: 1.0
 */
public abstract class BaseWebPushHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
    // 全局单例实例化唯一
    //public static ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    // 用户id和channel绑定
    //public static Map<String, Channel> userChannel = new ConcurrentHashMap<>();

    /**
     * 单通道发送
     * @param channel
     * @param message
     */
    public static final void send(Channel channel, String message) {
        channel.writeAndFlush(new TextWebSocketFrame(message));
    }

}
